package cn.edu.lingnan.service.user.impl;

import cn.edu.lingnan.bean.User;
import cn.edu.lingnan.repository.UserRepository;
import cn.edu.lingnan.service.user.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserRepository userRepository;

    @Override
    public User login(String userName, String passWord) {

        User loginUser = userRepository.findByUserNameAndPassWord(userName, passWord);
        return loginUser;
    }

    @Override
    public User saveUser(User user) {
        return userRepository.save(user);
    }

    @Override
    public User findUserById(Integer id){

        User user = userRepository.getOne(id);

        //Optional<User> user = userRepository.findById(id);

        return user;
    }
}
